﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Cms/Admin.Master" AutoEventWireup="true"
    CodeBehind="Photo.aspx.cs" Inherits="Aij1.Cms.Photo" %>

<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        html, body:
        {
            overflow: hidden;
        }
        .style1
        {
            width: 800px;
            margin-left: auto;
            margin-right: auto;
        }
        </style>
    <script type="text/javascript">
        function callback_CallbackComplete(s, e) {
            var key = e.result;
            lblTips.SetText(key);
            btnSubmit.SetEnabled(true);
            btnSaveToLocal.SetEnabled(true);
            if (key.indexOf("失败") < 0) {
                setTimeout("lblTips.SetText('')", 3000);
                document.getElementById('hdnPhotoId').value = callback.cpPhotoId;
            }
            if (key.indexOf("保存到本地成功") >= 0) {
                location = "?Id=" + callback.cpPhotoId;
            }
        }
        function submit_Click(s, e) {
            btnSubmit.SetEnabled(false);
            btnSaveToLocal.SetEnabled(false);
            lblTips.SetText("正在保存...");
            callback.PerformCallback();
        }

        function btnSaveToLocal_Click(s, e) {
            btnSubmit.SetEnabled(false);
            btnSaveToLocal.SetEnabled(false);
            lblTips.SetText("正在保存到本地...");
            callback.PerformCallback('savelocal');
        }

        function close_Click(s, e) {
            if (parent.RefreshData) parent.RefreshData();
            if (parent.HidePhotoWindow) parent.HidePhotoWindow();
            else close();
        }

        function addNext_Click(s, e) {
            var albumId = document.getElementById('hdnAlbumId').value;
            location = 'Photo.aspx?AlbumId=' + albumId;
        }

        function txtUrl_LostFocus(s, e) {
            var url = s.GetText();
            if (url.indexOf('~') != 0) {
                document.getElementById("urlImg").src = url || 'images/nopic.gif';
            }
        }

        function txtSnapShotUrl_LostFocus(s, e) {
            var url = s.GetText();
            if (url.indexOf('~') != 0) {
                document.getElementById("urlsImg").src = url || 'images/nopic.gif';
            }
        }

        function openUrl(obj) {
            if (obj.src.indexOf('nopic.gif') < 0)
            open(obj.src);
        }
    </script>
</asp:Content>
<asp:Content ID="CT2" ContentPlaceHolderID="PH" runat="server">
    <input type="hidden" value="<%=P.Oid %>" name="Id" id="hdnPhotoId" />
    <input type="hidden" value="<%=P.AlbumId.Oid %>" name="AlbumId" id="hdnAlbumId" />
    <table class="style1">
        <tr>
            <td colspan="2">
                <table width="100%">
                    <tr valign="top">
                        <td>
                            <div style="width: 600px; height: 350px; overflow: auto">
                            <img id="urlImg" src='<%=String.IsNullOrEmpty(P.Url)? "images/nopic.gif":ResolveClientUrl(P.Url) %>'
                                    alt='<%=P.Title %>' border="0" onclick="openUrl(this)" /></div>
                        </td>
                        <td width="120">
                            <img id="urlsImg" src='<%=String.IsNullOrEmpty(P.SnapShotUrl)?"images/nopic.gif":ResolveClientUrl(P.SnapShotUrl) %>'
                                style="width: <%=AlbumData.SnapWidth%>px; height: <%=AlbumData.SnapHeight%>px;" />
                        <dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="callback"
                    OnCallback="ASPxCallback1_Callback" OnCustomJSProperties="ASPxCallback1_CustomJSProperties">
                    <ClientSideEvents CallbackComplete="callback_CallbackComplete" />
                </dx:ASPxCallback>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td width="70">
                照片Url:
            </td>
            <td>
                <dx:ASPxTextBox ID="txtUrl" runat="server" Width="80%" MaxLength="200">
                    <ClientSideEvents LostFocus="txtUrl_LostFocus" />
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td>
                缩略图Url:
            </td>
            <td>
                <dx:ASPxTextBox ID="txtSnapShotUrl" runat="server" Width="80%" MaxLength="200">
                    <ClientSideEvents LostFocus="txtSnapShotUrl_LostFocus" />
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td>
                照片标题:
            </td>
            <td>
                <dx:ASPxTextBox ID="txtTitle" runat="server" Width="50%" MaxLength="50">
                </dx:ASPxTextBox>
            </td>
        </tr>
        <tr>
            <td>
                照片简介:
            </td>
            <td>
                <dx:ASPxMemo ID="txtIntro" runat="server" Height="60px" Width="100%">
                </dx:ASPxMemo>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                <table width="100%">
                    <tr>
                        <td width="80">
                            <dx:ASPxButton ID="btnSubmit" runat="server" Text="保存" Width="60px" ClientInstanceName="btnSubmit"
                                AutoPostBack="False">
                                <ClientSideEvents Click="submit_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="100">
                            <dx:ASPxButton ID="btnSaveToLocal" runat="server" Text="保存到本地" ClientInstanceName="btnSaveToLocal"
                                AutoPostBack="False">
                                <ClientSideEvents Click="btnSaveToLocal_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="80">
                            <dx:ASPxButton ID="btnClose" runat="server" Text="关闭" Width="60px" ClientInstanceName="btnClose"
                                AutoPostBack="False">
                                <ClientSideEvents Click="close_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="80">
                            <dx:ASPxButton ID="btnAddNext" runat="server" Text="继续添加" ClientInstanceName="btnClose"
                                AutoPostBack="False">
                                <ClientSideEvents Click="addNext_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td>
                            <dx:ASPxHyperLink ID="lnkPrevPhoto" runat="server" Text="上一张:" />
                        </td>
                        <td>
                            <dx:ASPxHyperLink ID="lnkNextPhoto" runat="server" Text="下一张:" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
                <dx:ASPxLabel ID="lblTips" runat="server" ClientInstanceName="lblTips" 
                    CssClass="tips">
                </dx:ASPxLabel>
            </td>
        </tr>
        </table>
</asp:Content>
